<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">
        <ui:define name="title">
            <h:outputText value="View Sales Inquiry # #{salesInquiryEntityController.selected.id}"></h:outputText>
        </ui:define>
        <ui:define name="content">
            <h:form rendered="#{loginBacking.viewSalesInquiry}">
                <p:panel header="View Sales Inquiry # #{salesInquiryEntityController.selected.id}">
                    <p:messages />
                    <br />
                    <h:panelGrid columns="6">
                        <h:outputText value="#{bundle.ViewSalesInquiryEntityLabel_salesLead}" rendered="#{salesInquiryEntityController.selected.salesLead!=null}"/>
                        <p:commandLink value="#{salesInquiryEntityController.selected.salesLead.firstName}&nbsp;#{salesInquiryEntityController.selected.salesLead.lastName}" action="#{salesLeadEntityController.viewSalesLeadFromInquiry}" rendered="#{salesInquiryEntityController.selected.salesLead!=null}" ajax="false"/>
                        <h:outputText value="" rendered="#{salesInquiryEntityController.selected.salesLead!=null}"/>
                        <h:outputText value="" rendered="#{salesInquiryEntityController.selected.salesLead!=null}"/>
                        <h:outputText value="Sales Lead Id:" rendered="#{salesInquiryEntityController.selected.salesLead!=null}"/>
                        <h:outputText value="#{salesInquiryEntityController.selected.salesLead}" rendered="#{salesInquiryEntityController.selected.salesLead!=null}"/>

                        <h:outputText value="#{bundle.ViewSalesInquiryEntityLabel_customer}" rendered="#{salesInquiryEntityController.selected.customer!=null}"/>
                        <p:commandLink value="#{salesInquiryEntityController.selected.customer.firstName}&nbsp;#{salesInquiryEntityController.selected.customer.lastName}" action="#{customerEntityController.viewCustomerFromInquiry}" rendered="#{salesInquiryEntityController.selected.customer!=null}" ajax="false"/>
                        <h:outputText value="" rendered="#{salesInquiryEntityController.selected.customer!=null}"/>
                        <h:outputText value="" rendered="#{salesInquiryEntityController.selected.customer!=null}"/>
                        <h:outputText value="Customer Id:" rendered="#{salesInquiryEntityController.selected.customer!=null}"/>
                        <h:outputText value="#{salesInquiryEntityController.selected.customer}" title="#{bundle.ViewSalesInquiryEntityTitle_customer}" rendered="#{salesInquiryEntityController.selected.customer!=null}"/>

                        <h:outputText value="#{bundle.ViewSalesInquiryEntityLabel_createdBy}"/>
                        <h:outputText value="#{salesInquiryEntityController.selected.createdBy.firstName}&nbsp;#{salesInquiryEntityController.selected.createdBy.lastName}"/>
                        <h:outputText value="" />
                        <h:outputText value="" />
                        <h:outputText value="#{bundle.ViewSalesInquiryEntityLabel_lastModifiedBy}"/>
                        <h:outputText value="#{salesInquiryEntityController.selected.lastModifiedBy.firstName}&nbsp;#{salesInquiryEntityController.selected.lastModifiedBy.lastName}"/>

                        <h:outputText value="#{bundle.ViewSalesInquiryEntityLabel_createdAt}"/>
                        <h:outputText value="#{salesInquiryEntityController.selected.createdAt}" title="#{bundle.ViewSalesInquiryEntityTitle_createdAt}">
                            <f:convertDateTime pattern="dd/MM/yyyy" />
                        </h:outputText>
                        <h:outputText value="" />
                        <h:outputText value="" />
                        <h:outputText value="#{bundle.ViewSalesInquiryEntityLabel_lastModifiedAt}"/>
                        <h:outputText value="#{salesInquiryEntityController.selected.lastModifiedAt}" title="#{bundle.ViewSalesInquiryEntityTitle_lastModifiedAt}">
                            <f:convertDateTime pattern="dd/MM/yyyy" />
                        </h:outputText>

                    </h:panelGrid>

                    <p:dataTable value="#{salesInquiryEntityController.selected.pqp}" var="pqp" style="border:solid 1px">
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Product"/>
                            </f:facet>
                            <h:outputText value="#{pqp.product.productName}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Quantity (Number of Case(s))"/>
                            </f:facet>
                            <h:outputText value="#{pqp.quantity}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Price Per Unit(S$)"/>
                            </f:facet>
                            <h:outputText value="#{pqp.pricePerUnit}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Sub Total Price (S$)"/>
                            </f:facet>
                            <h:outputText value="#{pqp.price}"/>
                        </p:column>
                        <p:columnGroup type="footer">  
                            <p:row>  
                                <p:column colspan="3" footerText="Total Price:"  
                                          style="text-align:left"  />  

                                <p:column footerText="S$ #{salesInquiryEntityController.viewCurrent.totalPrice}" style="text-align:left" />  

                            </p:row>  
                        </p:columnGroup>
                    </p:dataTable>
                    <br />
                </p:panel>
                <p:commandButton rendered="#{salesInquiryEntityController.selected.converted==false}" action="#{salesInquiryEntityController.prepareConvert}" value="Convert to Quotation" ajax="false"/>
                <p:commandButton rendered="#{salesInquiryEntityController.selected.converted!=false}" disabled="true" value="Convert to Quotation" ajax="false"/>
                &nbsp;
                <p:commandButton action="#{salesInquiryEntityController.prepareCreate}" value="New Inquiry" ajax="false"/>
                &nbsp;
                <p:commandButton action="#{salesInquiryEntityController.prepareList}" value="Show All Inquiries" ajax="false"/>
                &nbsp;
                <p:menuButton value="Employees Actions" rendered="#{salesInquiryEntityController.checkSystemUser()==true}"> 
                    <p:menuitem ajax="false" icon="ui-icon ui-icon-trash" action="#{salesInquiryEntityController.destroyAndView}" value="Delete" rendered="#{loginBacking.deleteSalesInquiry}"/>
                </p:menuButton>
            </h:form>
        </ui:define>
    </ui:composition>

</html>


